package cpoo.oldNotUsed;

import java.awt.Graphics;
import java.awt.Image;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.awt.image.BufferedImage;

import javax.swing.JFrame;

public class AwtImage extends JFrame {
	public static final long serialVersionUID = 2;
	Image img;

	public AwtImage(BufferedImage image) {
		super("Image Frame");
		img = image;
		setSize(image.getWidth()+60, image.getHeight()+60);
		setVisible(true);
		addWindowListener(new WindowAdapter() {
			public void windowClosing(WindowEvent we) {
				dispose();
			}
		});
		repaint();
	}

	public void update(Graphics g) {
		paint(g);
	}

	public void paint(Graphics g) {
		if (img != null)
			g.drawImage(img, 30, 30, this);
		else
			g.clearRect(0, 0, getSize().width, getSize().height);
	}
}
